<!-- 课程设置 -->
<template>
  <div class="assessment-edit-plan-container">
    <div class="my-form-container" style="margin:0;width:100%;height: 100%">
      <el-form
        :model="newCourseList"
        ref="ruleForm"
        class="demo-ruleForm"
      >
        <el-form-item class="my-form-item" >
          <div class="my-form-item-label">
            名称
          </div>
          <el-input v-model="mc" readonly prop="mc"></el-input>
          <div class="my-form-item-label"> 版本
          </div>
          <el-input v-model="bb" readonly prop="bb"></el-input>
        </el-form-item>
        <el-row class="my-form-item" style="margin-top:15px">
          <el-col :span="24" style="background: rgba(0, 76, 167, 0.1)">
            <div style="line-height: 79px; margin: 0 auto; color: #004ca7;font-weight: 600">
              {{topType}}
            </div>
          </el-col>
        </el-row>
        <!-- <el-dialog
          title="选择其他可开课学期"
          :visible.sync="dialogVisible"
          width="50%"
          class="manual-entry-container"
        >
          <el-table
            :data="dialogData"
            border
            style="width: 100%"
            class="table-data"
            row-class-name="row-class"
            cell-class-name="cell-class"
            header-row-class-name="header-row-class"
            header-cell-class-name="header-cell-class"
          >
            <el-table-column prop="xn" label="学年" align="center">
              <template slot-scope="scope">
                <input type="checkbox" v-model="scope.row.xn" value="scope.row.label" name="xqCheck" @change="handleCheckAllChange(scope)">{{scope.row.label}}
              </template>
            </el-table-column>
            <el-table-column label="学期" align="center">
              <template slot-scope="scope">
                <input type="checkbox" v-model="scope.row.xq" name="xqCheck" value="夏季学期">夏季学期
                <input type="checkbox" v-model="scope.row.xq" name="xqCheck" value="秋季学期">秋季学期
                <input type="checkbox" v-model="scope.row.xq" name="xqCheck" value="冬季学期">冬季学期
              </template>
            </el-table-column>
          </el-table>
          <div style="width:200px;display:flex;border:none;margin-top:20px">
            <el-button type="warning" plain @click="submitCheck">保 存</el-button>
            <el-button type="danger" plain @click="pjByIdGuideClose">取 消</el-button>
          </div>
        </el-dialog> -->
        <el-row>
          <div class="my-border-container" style="margin: 50px auto 20px;position: relative;">
            <div style="display:flex;stretch">
              <div class="leftTop">
                <el-input type="textarea" v-model="topType" disabled style="width: 166px;position: absolute;top:48%;padding-left:10px"></el-input>
              </div>
              <div class="leftRight">
                <el-tree
                  ref="treeData"
                  :data="setTree"
                  :props="defaultProps"
                  default-expand-all="true"
                  :current-node-key="currentLivingId"
                  @node-click="handleNodeClick"
                  node-key="id"
                  highlight-current
                ></el-tree>
                <!-- @node-click="{()=> handleNodeClick()}" -->
                <div v-show="isHaveChild">
                  <!-- <el-form-item label="额定学分：" style=""> -->
                  <div>
                    <span style="color:rgb(0 76 167);margin-left:37px">额定学分：</span>
                    <span style="color:red;margin-right:10px">*</span>
                    <el-input v-model="newCourseList.edxf" class="treeInput" type="number" size="small"></el-input>
                    <!-- </el-form-item> -->
                    <!-- <el-form-item label="额定学时：" style="display:inline-flex;"> -->
                    <span style="color:rgb(0 76 167)">额定学时：</span>
                    <span style="color:red;margin-right:10px">*</span>
                    <el-input v-model="newCourseList.edxs" class="treeInput" type="number" size="small"></el-input>
                    <!-- </el-form-item> -->
                    <!-- <el-button type="success" icon="el-icon-add" @click="newCourse" style="position: absolute;">新增课程</el-button> -->
                    <div class="lucj-import-button" @click="newCourse">
                      <!-- <img src="../../../assets/assessment/icon-plan-record-detail.png" style="width:17px;height:17px" alt="" /> -->
                      新增课程
                    </div>
                  </div>
                  <div style="border:1px solid rgb(199 215 235)"></div>
                  <el-table
                    :data="tableData"
                    style="width:95%;margin:19px auto"
                    max-height="220px"
                    class="xpaas-table-class"
                    row-class-name="xpaas-row-class"
                    cell-class-name="xpaas-cell-class"
                    header-row-class-name="xpaas-header-row-class"
                    header-cell-class-name="xpaas-header-cell-class"
                  >
                    <el-table-column prop="sc" label="删除" align="center" width="120">
                      <template slot-scope="scope" >
                        <div
                          class="plsc-button"
                          @click="delOne(scope.row.id,scope.$index)"
                          style="width: 70px;margin:0 auto"
                        >
                          <span>删 除</span>
                        </div>
                        <!-- <el-button type="danger" icon="el-icon-delete" size="mini" @click="delOne(scope.row.id,scope.$index)">删除</el-button> -->
                      </template>
                    </el-table-column>
                    <el-table-column prop="courseCode" align="center" label="课程编号（名称）">
                      <template slot-scope="scope">
                        {{ scope.row.kcph }}（{{ scope.row.coursename }}）
                      </template>
                    </el-table-column>
                    <el-table-column prop="xuefen" align="center" label="学分" width="70" type="number">
                    </el-table-column>
                    <el-table-column prop="xuehour" align="center" label="总学时" width="80" type="number">
                    </el-table-column>
                    <el-table-column prop="xnxq" align="center" label="学年/学期" :render-header="addRedStar">
                      <template slot-scope="scope">
                        <el-form-item class="my-form-item" id="selForm">
                          <el-select v-model="scope.row.xnxq" placeholder="请选择" @change="changexnSel(scope.row)">
                            <el-option
                              v-for="(item,index) in xnList"
                              :key="index"
                              :label="item"
                              :value="item"
                            >
                            </el-option>
                          </el-select>
                          <el-select v-model="scope.row.season" placeholder="请选择" @change="changexqSel(scope.row)">
                            <el-option
                              v-for="(item,index) in xqList"
                              :key="index"
                              :label="item"
                              :value="item"
                            >
                            </el-option>
                          </el-select>
                        </el-form-item>
                      </template>
                    </el-table-column>
                    <el-table-column prop="xxlx" align="center" label="修习类型" :render-header="addRedStar" width="100">
                      <template slot-scope="scope">
                        <el-form-item class="my-form-item" id="selForm">
                          <el-select v-model="scope.row.xxlx" placeholder="请选择" @change="changeXXtype(scope.row)">
                            <el-option
                              v-for="(item,index) in xxlxList"
                              :key="index"
                              :label="item"
                              :value="item"
                            >
                            </el-option>
                          </el-select>
                        </el-form-item>
                      </template>
                    </el-table-column>
                    <el-table-column prop="khfs" align="center" label="考核方式" :render-header="addRedStar" width="100">
                      <template slot-scope="scope">
                        <el-form-item class="my-form-item" id="selForm">
                          <el-select v-model="scope.row.khfs" placeholder="请选择" @change="changeKhfs(scope.row)">
                            <el-option
                              v-for="(item,index) in khfsList"
                              :key="index"
                              :label="item"
                              :value="item"
                            >
                            </el-option>
                          </el-select>
                        </el-form-item>
                      </template>
                    </el-table-column>
                    <el-table-column
                      prop="qtkkkxq "
                      align="center"
                      label="其他可开课学期"
                      width="300"
                    >
                      <template slot-scope="scope">
                        <el-form-item class="my-form-item" id="selForm">
                          <el-cascader
                            v-model="scope.row.qtkkkxq"
                            :options="options"
                            :props="props"
                            clearable
                            collapse-tags='true'
                            @change="changeCas(scope.row)"
                            placeholder="请先选择学年/学期"
                            @visible-change="changeValue1($event,scope.row)"
                            style="margin: 0 auto;width:220px"
                          >
                          </el-cascader>
                        </el-form-item>
                      </template>
                    </el-table-column>
                  </el-table>
                </div>
              </div>
            </div>
          </div>
        </el-row>
        <!-- max-height="400px" -->
        <el-table
          :data="yearTable"
          style="width: 95%;margin: 20px auto"
          class="xpaas-table-class"
          row-class-name="xpaas-row-class"
          cell-class-name="xpaas-cell-class"
          header-row-class-name="xpaas-header-row-class"
          header-cell-class-name="xpaas-header-cell-class"
          :span-method="objectSpanMethod"
          :header-cell-style="handerMethod"
        >
          <el-table-column prop="" align="center" label="">
            <template slot-scope="scope">
              总计：学时（门数）
            </template>
          </el-table-column>
          <!-- <el-table-column prop="year" align="center" width="120" v-for="(item,index) in xnList"
              :key="index"
              :label="item"
              :value="item">
          </el-table-column> -->
          <!-- <el-table-column v-for="item in yearTable" prop="season" align="center" :label="item.year">
            <template slot-scope="scope">
              {{ scope.row.classHours }}【{{ scope.row.numbers }}】
            </template>
          </el-table-column> -->
          <el-table-column prop="year" align="center" label="学年">
          </el-table-column>
          <el-table-column prop="season" align="center" label="学期">
          </el-table-column>
          <el-table-column prop="classHours" align="center" label="总学时">
            <template slot-scope="scope">
              {{ scope.row.classHours }}【{{ scope.row.numbers }}】
            </template>
          </el-table-column>
        </el-table>
        <!-- <div class="my-border-container" style="margin: 20px auto">
           <table border="1">
            <tr>
              <th rowspan="1"></th>
              <th
                v-for="(item,index) in xnList"
                :key="index"
                :label="item"
                :value="item"
              > {{item}} </th>
              </tr>
              <tr>
                <td rowspan="1">秋</td>
                <td rowspan="1">春</td>
                <td rowspan="1">夏</td>
                <td rowspan="1">春</td>
                <td rowspan="1">秋</td>
                <td rowspan="1">秋</td>
                <td rowspan="1">春</td>
                <td rowspan="1">东</td>
              </tr>
          </table> 
        </div> -->
      </el-form>
    </div>
    <div class="button-group">
      <div @click="getsubmit">
        <div>保 存</div>
      </div>
      <div @click="lookDetail">
        <div>预 览</div>
      </div>
      <div @click="cancelAdd">
        <div>取 消</div>
      </div>
      <!-- <el-button type="success" @click="getsubmit">保 存</el-button>
      <el-button type="warning" @click="lookDetail" style="margin-left:60px">预 览</el-button>
      <el-button type="danger" @click="cancelAdd" style="margin-left:60px">取 消</el-button> -->
    </div>
  </div>
</template>

<script>
import { setCourse,reqsetCourseSave,reqRemoveSetting } from "@/api/propositionReview/approval";
export default {
  data() {
    return {
      currentNodeKey:"",//默认节点最高级高亮
      currentNodeName:"",//默认节点最高级高亮
      isIndeterminate: false,
      checkXn:[],
      checkXq:[],
      data: [],
      tableData: [],// 外侧表格数据
      setTree:[],//树形分类
      yearTable:[],//学年表格
      clickTreeData:'',//点击节点之后获取对应的数据
      props: { multiple: true },
      options: [
        {
          value: '第1学年',
          label: '第1学年', disabled:true,
          children: [
            { value: '夏季学期', label: '夏季学期', disabled:true },
            { value: '秋季学期', label: '秋季学期', disabled:true },
            { value: '春季学期', label: '春季学期', disabled:true}
          ]
        },
        {
          value: '第2学年',
          label: '第2学年', disabled:true,
          children: [
            { value: '夏季学期', label: '夏季学期', disabled:true },
            { value: '秋季学期', label: '秋季学期', disabled:true },
            { value: '春季学期', label: '春季学期', disabled:true }
          ]
        },
        {
          value: '第3学年',
          label: '第3学年', disabled:true,
          children: [
            { value: '夏季学期', label: '夏季学期', disabled:true },
            { value: '秋季学期', label: '秋季学期', disabled:true },
            { value: '春季学期', label: '春季学期', disabled:true }
          ]
        },
        {
          value: '第4学年',
          label: '第4学年', disabled:true,
          children: [
            { value: '夏季学期', label: '夏季学期', disabled:true },
            { value: '秋季学期', label: '秋季学期', disabled:true},
            { value: '春季学期', label: '春季学期', disabled:true}
          ]
        },
        {
          value: '第5学年',
          label: '第5学年', disabled:true,
          children: [
            { value: '夏季学期', label: '夏季学期' , disabled:true},
            { value: '秋季学期', label: '秋季学期' , disabled:true},
            { value: '春季学期', label: '春季学期' , disabled:true}
          ]
        },
      ],
      defaultProps: {
        children: "children",
        label: "name",
      },
      trainingprogramlid:'',//培养方案id
      coursetypeid:"",//课程分类id
      mc: "",
      bb: "",
      newCourseList:{
        edxf:"",
        edxs:"",
        id:"",
        xnxq:"",
        kcid:"",
        season:"",
        xxlx:"",
        khfs:"",
        qtkkkxq:"",
        kcph:"",
        xuefen:"",
        xuehour:"",
        pyfaid:"",
        kctypeid:"",
        kctypename:"",
      },
      tablelist: {},
      xnList:['第1学年','第2学年','第3学年','第4学年','第5学年'],
      // xqList:[{label:'夏',value:'夏季学期'},{label:'秋',value:'秋季学期'},{label:'春',value:'春季学期'}],
      xqList:['夏','秋','春'],
      xxlxList:['必修', '选修'],
      khfsList:['考试','笔试','考查','论文'],
      spanArr:[],
      pos:0,
      topType:'',
      isHaveChild:false,
    };
  },
  mounted() {
    this.tablelist = JSON.parse(localStorage.getItem('setCourse'));
    this.mc = this.tablelist.mc;
    this.bb = this.tablelist.bb;
    this.trainingprogramlid = this.tablelist.id;
    this.coursetypeid = this.tablelist.planFlId;
    this.newCourseList.pyfaid = this.tablelist.id;
    this.getListData();
    window.onbeforeunload = function(e) {
      localStorage.removeItem("currentLight");
      localStorage.removeItem("currentLightName");
      localStorage.removeItem("addCourse");
      this.getListData();
    }
    this.getSpanArr();
  },
  methods: {
    // 给表头加必选标识
    addRedStar(h, { column }) { 
      return [h('span', { style: 'color: red' }, '*'), h('span', ' ' + column.label)]
    },
    getSpanArr() {
      let id = this.tablelist.id;
      let data = [];
      setCourse(id).then(res=>{
        if(res.data.code == 200){
          data = res.data.data.classHours;
          for (var i = 0; i < data.length; i++) {
            if (i === 0) {
              this.spanArr.push(1);
              this.pos = 0;
            } else {
              if (data[i].year === data[i - 1].year) {
                this.spanArr[this.pos] += 1;
                this.spanArr.push(0);
              } else {
                this.spanArr.push(1);
                this.pos = i;
              }
            }
          }
        }
      })
    },
    // handerMethod({ row, column, rowIndex, columnIndex }) {
    //   if (rowIndex === 0) {
    //     if (columnIndex === 0) {
    //       this.$nextTick(() => {
    //           if (document.getElementsByClassName(column.id).length !== 0) {
    //               document
    //                   .getElementsByClassName(column.id)[0]
    //                   .setAttribute('colSpan', 2);
    //           }
    //       });
    //     }
    //   }
    //   return{background:'#eef1f6',color:'#606266',fontWeight:'800',textAlign:'center'}
    // },
    objectSpanMethod({ row, column, rowIndex, columnIndex }) {
      if (columnIndex === 0) {
        if (rowIndex % this.yearTable.length === 0) {
          return {
            rowspan: this.yearTable.length,
            colspan: 1,
          };
        } else {
          return {
            rowspan: 0,
            colspan: 0,
          };
        }
      }
      if (columnIndex === 1) {
        const _row = this.spanArr[rowIndex];
        const _col = _row > 0 ? 1 : 0;
        return {
          rowspan: _row,
          colspan: _col,
        };
      }
    },
    //选择学年下拉框
    changexnSel(val){
      // this.newCourseList.xnxq = val.xnxq;
    },
    //选择学期下拉框
    changexqSel(val){
      // this.newCourseList.season = val.season;
    },
    changeXXtype(val){
      // this.newCourseList.xxlx = val.xxlx;
    },
    changeKhfs(val){
      // this.newCourseList.khfs = val.khfs;
    },
    //（其他可选择学期）级联下拉设置禁用
    changeValue1(e,val){
      if(val.xnxq && val.season){
        this.options.forEach(item=> {
          item.disabled = false;
          item.children.forEach(j=> {
            j.disabled = false;
            var value = j.value.split('季学期').join("");
            if(item.value == val.xnxq && value == val.season){
              j.disabled = true;
            }
          })
        })
      } else {
        this.options.forEach(item=> {
          item.disabled = true;
        })
      }
    },
    //级联下拉框选择
    changeCas(val){
      /* let arr = [];
      let newList = [];
      if(val.qtkkkxq.length > 0){
        for(let i in val.qtkkkxq) {
          arr.push(val.qtkkkxq[i])
          for(let j in val.qtkkkxq[i]) {
            newList.push(val.qtkkkxq[i][j])
            console.log(newList)
            this.newCourseList.qtkkkxq = newList.toString();
          }
        }
      } */
    },
    //第一个表格内单独操作每一列的删除按钮
    delOne(id,index){
      this.$confirm('确认要删除吗？')
        .then(_ => {
          reqRemoveSetting(id).then(res=>{
            if(res.data.code == 200){
              this.$message({
                type:'info',
                message:'成功删除！'
              })
            } else {
              this.$message({
                type:'error',
                message:'删除失败！'
              })
            }
          })
          this.tableData.splice(index, 1);
          localStorage.removeItem('addCourse');
          localStorage.setItem('addCourse',JSON.stringify(this.tableData));
      })
    },
    //获取树形父级节点并设置高亮
    getListData() {
      const id = this.tablelist.id;
      setCourse(id).then(res => {
        if(res.data.data.courseTypeVOList.length > 0 && res.data.data.courseTypeVOList[0].childCategory.length > 0){
          this.isHaveChild = true;
        }
        this.topType = res.data.data.courseTypeVOList.length > 0 ? res.data.data.courseTypeVOList[0].flmc: ''; 
        const data = this.clickTreeData = res.data.data.courseTypeVOList[0].childCategory;
        this.newCourseList.edxf = data.length && data[0].edxf ? data[0].edxf : '';
        this.newCourseList.edxs = data.length && data[0].edxs ? data[0].edxs : '';
        this.yearTable = res.data.data.classHours.length > 0 ? res.data.data.classHours : [];
        if(data.length > 0){
          var currentLight = localStorage.getItem("currentLight");
          var currentLightName = localStorage.getItem("currentLightName");
          if(currentLight){
            this.currentNodeKey = currentLight;
          } else {
            this.currentNodeKey = data[0].id;
            localStorage.setItem("currentLight",data[0].id);
          }
          currentLightName ? this.currentNodeName = currentLightName : this.currentNodeName = data[0].flmc;
          // console.log(currentLight)
          const tableData = JSON.parse(localStorage.getItem('addCourse'));
          if(tableData){
           tableData.forEach(item => {
              const removeDuplicateObj = (tableData) => {
                let obj = {};
                tableData = tableData.reduce((newArr, next) => {
                  obj[next.kcid] ? "" : (obj[next.kcid] = true && newArr.push(next));
                  return newArr;
                }, []);
                return tableData;
              };
              var newArr = removeDuplicateObj(tableData);
              this.tableData = newArr;
              this.newCourseList.id = item.id;
              this.newCourseList.xuefen = item.credit;
              this.newCourseList.xuehour = item.totalHours;
              this.newCourseList.kcid = item.id;
              this.newCourseList.kcph = item.courseCode;
              this.newCourseList.kctypeid = currentLight;
              this.newCourseList.kctypename = currentLightName;
            })
            this.currentNodeKey = currentLight;
          } else {
            this.tableData = data[0].trainingProgramCourses;
            if(this.tableData.length > 0){
              this.tableData.forEach((item)=>{
                if(item.qtkkkxq == ""){
                  item.qtkkkxq = "";
                } else {
                  typeof item.qtkkkxq == 'string' ? item.qtkkkxq = this.arrToTwoDim(item.qtkkkxq.split(",")) : item.qtkkkxq = item.qtkkkxq;
                }
              })
            }
            // this.newCourseList.edxf = ;
          }
          this.$nextTick(()=> {
            this.$refs.treeData.setCurrentKey(this.currentNodeKey);
          })
          data.forEach(k => {
            this.setTree.push({
              id: k.id,
              name: k.flmc,
              children: this.getListChild(k.childCategory)
            })
          })
        }
      });
    },
    //获取树形子级节点
    getListChild(data) {
      let tree =[];
      if(data.length){
        data.forEach(k => {
          tree.push({
            id: k.id,
            name: k.flmc,
            children:this.getListChild(k.childCategory)
          })
        })
      }
      return tree
    },
    arrToTwoDim(arr, n = 2) {
      var arr2 = []
      for (var i = 0, j = 0; i < arr.length; i += n) {
          // 初始化数组单个元素为数组
          arr2[j] = []
          for (var k = 0; k < n; k++) {
              if (i + k < arr.length)
                  arr2[j].push(arr[i + k])
          }
          j++
      }
      return arr2
    },
    //循环接口数据（根据点击子级id）
    forTableData(id,res){
      res.forEach(item=>{
        if(item.id == id){
          this.newCourseList.edxf = item.edxf ? item.edxf : '';
          this.newCourseList.edxs = item.edxs ? item.edxs : '';
          this.tableData = [];
          this.tableData = item.trainingProgramCourses;
          if(item.trainingProgramCourses.length > 0){
            this.tableData.forEach((item)=>{
              if(item.qtkkkxq == ""){
                item.qtkkkxq = "";
              } else {
                typeof item.qtkkkxq == 'string' ? item.qtkkkxq = this.arrToTwoDim(item.qtkkkxq.split(",")) : item.qtkkkxq = item.qtkkkxq;
                ;
              }
            })
          }
          localStorage.setItem('addCourse',JSON.stringify(this.tableData));
        } else {
          this.newCourseList.edxf = '';
          this.newCourseList.edxs = '';
          this.forTableData(id,item.childCategory)
        }
      })
    },
    //点击子级节点事件
    handleNodeClick(event){
      localStorage.setItem('currentLight',event.id);
      localStorage.setItem('currentLightName',event.name);
      this.clickTreeData.forEach(item=>{
        this.newCourseList.edxf = item.edxf ? item.edxf : '';
        this.newCourseList.edxs = item.edxs ? item.edxs : '';
        if(item.id == event.id){
          this.tableData = [];
          this.tableData = item.trainingProgramCourses;
          if(this.tableData.length > 0){
            this.tableData.forEach((item)=>{
              if(item.qtkkkxq == ""){
                item.qtkkkxq = "";
              } else {
                typeof item.qtkkkxq == 'string' ? item.qtkkkxq = this.arrToTwoDim(item.qtkkkxq.split(",")) : item.qtkkkxq = item.qtkkkxq;
              }
            })
          }
          localStorage.setItem('addCourse',JSON.stringify(this.tableData));
        } else {
          this.newCourseList.edxf = '';
          this.newCourseList.edxs = '';
          this.forTableData(event.id,item.childCategory)
        }
      })
    },
    //点击新增课程
    newCourse(){
      this.$router.push({
        path: "/admin/training/addTrainCourse",
      });
      localStorage.setItem('addCourse',JSON.stringify(this.tableData));
    },
    //预览（详情）
    lookDetail(){
      this.$router.push({
        path: "/admin/training/newLookNoedit",
        query: {
          id: this.tablelist.id,
          edxf:this.newCourseList.edxf,
          edxs:this.newCourseList.edxs,
        }
      });
      localStorage.setItem("addCourse",JSON.stringify(this.tableData));
    },
    //保存
    getsubmit() {
      let isNull = false;
      this.tableData.forEach((item)=>{
        item.edxf = this.newCourseList.edxf;
        item.edxs = this.newCourseList.edxs;
        item.kctypeid = localStorage.getItem("currentLight");
        item.kctypename = localStorage.getItem("currentLightName");
        item.pyfaid = this.tablelist.id;
        if(item.qtkkkxq instanceof Array == true){
          item.qtkkkxq =item.qtkkkxq.toString();
        }
        if(item.edxf == '' || item.edxs == '' || item.xnxq == '' || item.season == '' || item.xxlx == '' || item.khfs == ''){
          isNull = true
        }
      })
      let obj = {
        "coursetypeid":this.coursetypeid,
        "trainingProgramCourses":this.tableData,
        "trainingprogramlid":this.trainingprogramlid
      }
      if(isNull){
        this.$message({
          type:'info',
          message:'必填项不能为空！'
        })
        return
      } else {
        let result = null;
        result = reqsetCourseSave(obj);
        result.then(res =>{
          if (res.data.code == 200) {
            this.$message({ type: "success", message: "保存成功！" });
            this.$router.push({
              path: "/admin/training/trainings", //要跳转的页面的路由
            });
            localStorage.removeItem("addCourse");
            localStorage.removeItem("currentLight");
            localStorage.removeItem("currentLightName");
            return "ok";
          }
        })
      }
    },
    //取消
    cancelAdd(){
      this.$router.push({
        path: "/admin/training/trainings", //要跳转的页面的路由
      });
      localStorage.removeItem("addCourse");
      localStorage.removeItem("currentLight");
      localStorage.removeItem("currentLightName");
    }
  },
};
</script>
<style lang="less" scoped>
/deep/.el-textarea.is-disabled .el-textarea__inner{
  color:#F86900;
  font-size: 18px;
  border: none;
}
.leftTop{
  width: 172px;
  height: 450px;
  float: left;
  line-height: 450px;
  color:#F86900;
  font-size: 18px;
  font-weight: bold;
  // padding-left: 57px;
  border-right: 2px solid rgb(199 215 235);
}
.leftRight {
  width: 89%;
  float: right;
}
/deep/.el-tree {
  font-weight: 500;
  color: #004ca7;
  .el-tree-node__content {
    margin-bottom: 8px;
    .el-tree-node__label {
      font-size: 18px;
      // font-weight: 700;
    }
  }
}
.plsc-button {
  height: 28px;
  background: #ffefef;
  border: 1px solid #fa5339;
  border-radius: 6px;
  color: #ff3819;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  img {
    width: 14px;
    height: 14px;
    background-size: 100% 100%;
    background-repeat: no-repeat;
    margin: 2px 5px 0 0;
  }
}
 #selForm{
   border: none;
   height: 50px;
 }
// /deep/.el-table th, .el-table tr{
//   background-color: #4D81C0 !important;
// }
.lucj-import-button{
  width: 100px;
  height: 30px;
  background: #f1fff8;
  border: 1px solid #02c86c;
  border-radius: 6px;
  color: #02c86c;
  display: inline-block;
  /* align-items: center;
  justify-content: center; */
  cursor: pointer;
  line-height: 30px;
  margin-left: 15px;
  text-align: center;
  position: relative;
  // top: -15px;
}
/deep/.el-dialog__wrapper .el-table--border td,.el-dialog__wrapper .el-table--border th {
  border-right: 1px solid #EBEEF5;
}

.manual-entry-container {
  .el-dialog__body {
    height: 200px;
    > div {
      width: 1014px;
      border: 1px solid rgba(0, 76, 167, 0.8);
      border-radius: 6px;
      margin: 0 auto;
      > div {
        border-bottom: 1px solid rgba(0, 76, 167, 0.39);
        &:last-child {
          border-bottom: none;
        }
        > div {
          display: flex;
          > div {
            height: 96px;
            display: flex;
            align-items: center;
            justify-content: center;
            &:nth-child(1) {
              width: 450px;
              text-align: center;
              font-size: 16px;
              font-weight: bold;
              color: #004ca7;
              background: rgba(77, 129, 192, 0.1);
            }
            &:nth-child(2) {
              padding-left: 19px;
            }
          }
        }
      }
    }
  }

  .el-dialog__footer {
    padding-bottom: 43px;
  }

  .dialog-footer {
    > button {
      width: 90px;
      height: 36px;
      background: #fff6ef;
      border: 1px solid #f3b815;
      border-radius: 6px;
      background: rgba(255, 246, 239, 1);
      font-size: 18px;
      color: #f3b815;
    }
  }
}

/deep/.el-table th,
.el-table tr {
  color: #004ca7;
}
.table-data {
  width: 100%;
  border: 0.8px solid #004ca7;
  border-radius: 9px;
  font-size: 14px;
  font-family: Microsoft YaHei;
  font-weight: 400;
  color: #004ca7;
}
/deep/.el-tabs {
  width: 90%;
  margin: 0 auto;
}
.bk {
  /deep/ .el-input__inner {
    border-radius: 4px;
    border: 1px solid #004ca7;
  }
}
.zyjs {
  width: 30% !important;
  margin-left: 40px !important;
  /deep/ .el-input__inner {
    height: 70px !important;
    border-radius: 4px;
    border: 1px solid #004ca7;
  }
}
.el-input {
  width: 26%;
  display: flex;
  align-items: center;
  margin-left: 40px;
  margin-right: 40px;
}
.treeInput{
  width: 160px;
  margin: 0 20px 0 0;
  width: 120px; 
  display:inline-flex;
}
.el-button{
  // position: absolute;
  // top: 3px;
  font-weight: 600;
  border-radius: 4px;
}
.my-form-item {
  height: 85px;
  border-bottom: 1px solid rgba(0, 76, 167, 0.39);
  margin-bottom: 0;
  > div {
    display: flex;
    height: 100%;
    &:nth-child(2) {
      .my-form-item-label {
        border-left: 1px solid rgba(0, 76, 167, 0.39);
      }
    }
    .my-form-item-label{
      width: 220px;
      padding-left: 90px;
      background: rgba(0, 76, 167, 0.1);
      display: flex;
      flex: none;
      align-items: center;
      color: #004CA7;
      font-size: 16px;
      font-weight: bold;
      border-left: 1px solid rgba(0, 76, 167, 0.39);
      margin-left: -1px;
      .mustW {
        color: red;
      }
    }
    .el-form-item__content{
      display: flex;
    }
  }
}
.el-date-editor {
  width: 38%;
}
.choose-ypr-container {
  width: 100%;
  margin: 0px auto;

  .choose-ypr-search-container {
    .el-input--prefix .el-input__inner {
      padding-left: 30px;
    }

    .el-input__inner {
      &::placeholder {
        color: #b8b8b8;
      }

      &::-webkit-input-placeholder {
        /* WebKit browsers 适配谷歌 */
        color: #b8b8b8;
      }

      &:-moz-placeholder {
        /* Mozilla Firefox 4 to 18 适配火狐 */
        color: #b8b8b8;
      }

      &::-moz-placeholder {
        /* Mozilla Firefox 19+ 适配火狐 */
        color: #b8b8b8;
      }

      &:-ms-input-placeholder {
        /* Internet Explorer 10+  适配ie*/
        color: #b8b8b8;
      }
    }

    display: flex;
    flex-direction: row;
    align-items: center;

    .title {
      font-size: 18px;
      font-family: Microsoft YaHei;
      font-weight: bold;
      line-height: 20px;
      color: #004ca7;
      margin-right: 5px;
    }

    .search-button {
      width: 77px;
      height: 28px;
      line-height: 28px;
      background: #f1f8fe;
      border: 1px solid #51aef6;
      border-radius: 6px;
      cursor: pointer;
      display: flex;
      flex-direction: row;
      align-items: center;
      justify-content: center;

      > span {
        font-size: 16px;
        font-family: Microsoft YaHei;
        font-weight: 400;
        color: #51aef6;
      }

      > img {
        width: 20px;
        height: 20px;
        margin-right: 4px;
      }
    }

    .button-list {
      display: flex;
      flex-direction: row;
      align-items: center;
      margin-left: 21px;

      .button-item {
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: center;
        position: relative;
        width: 69px;
        height: 27px;
        line-height: 27px;
        border: 1px solid #004ca7;
        border-radius: 4px;
        margin-right: 10px;
        text-align: center;
        font-size: 14px;
        font-family: Microsoft YaHei;
        font-weight: 400;
        color: #004ca7;

        .del-icon {
          position: absolute;
          right: 0px;
          top: 0px;
          width: 12px;
          height: 12px;
          padding: 2px;
        }
      }
    }
  }

  .choose-ypr-container .choose-ypr-table-container .el-table__header th {
    padding: 0;
    height: 57px;
    background-color: #edf2f9;
    font-size: 16px;
    font-family: Microsoft YaHei;
    font-weight: bold;
    line-height: 20px;
    color: #004ca7;
  }

  /deep/ .el-table .cell {
    color: #004ca7;
  }

  .choose-ypr-table-container {
    margin-top: 30px;

    .el-table td,
    .el-table th.is-leaf,
    .el-table--border,
    .el-table--group {
      border-color: #c7d7eb;
    }

    .el-table__header tr,
    .el-table__header th {
      padding: 0;
      height: 57px;
      background-color: #edf2f9;
      font-size: 16px;
      font-family: Microsoft YaHei;
      font-weight: bold;
      line-height: 20px;
      color: #004ca7;
    }

    .el-table__body tr,
    .el-table__body td {
      padding: 0;
      height: 51px;
    }

    .table-data {
      width: 100%;
      border: 0.8px solid #004ca7;
      border-radius: 9px;
      font-size: 14px;
      font-family: Microsoft YaHei;
      font-weight: 400;
      color: #004ca7;
    }
  }
}

.assessment-container {
  .el-dialog__body {
    height: 251px;
  }

  .el-dialog__footer {
    padding: 10px 20px 45px;
  }

  .el-checkbox__inner:hover {
    border-color: #004ca7;
  }

  .el-checkbox__inner {
    border: 1px solid #004ca7;
    border-radius: 0;
    height: 18px;
    width: 18px;
  }

  .el-checkbox__inner::after {
    height: 10px;
    left: 6px;
  }

  .el-checkbox__input.is-checked .el-checkbox__inner,
  .el-checkbox__input.is-indeterminate .el-checkbox__inner {
    background-color: #004ca7;
    border-color: #004ca7;
  }

  .el-checkbox__input.is-checked + .el-checkbox__label {
    color: #004ca7;
  }

  .el-checkbox.is-bordered.is-checked {
    border-color: #004ca7;
  }
  .el-checkbox:last-of-type {
    margin-right: 30px !important;
  }

  .el-checkbox__input.is-focus .el-checkbox__inner {
    border-color: #004ca7;
  }
}

.cz-save {
  box-sizing: border-box;
  line-height: 44px;
  border-radius: 4px;
  font-size: 12px;
  font-family: Microsoft YaHei;
  font-weight: 400;
  text-align: center;
  margin-top: 70px;
  margin-left: 40px;
  display: flex;
  flex-direction: row;
  cursor: pointer;
  align-content: center;
  justify-content: center;
  align-items: center;
}

.jf-save {
  display: flex;
  align-items: center;
  margin-left: 48px;
}

.fileClass {
  position: relative;
  cursor: pointer;

  .save {
    width: 120px;
    height: 50px;
    position: absolute;
    top: 0;
    left: 0;
    opacity: 0;
    color: #fff;
    background: #303133;
  }
}

.my-form-item-value {
  font-size: 16px;
  color: #004ca7;
  height: 100%;
  flex: 1;
  line-height: 60px;
  padding-left: 38px;
  display: flex;
  align-items: center;
}

.assessment-edit-plan-container {
  .assessment-design {
    .el-textarea__inner {
      resize: none;
      font-size: 16px;
      color: rgba(0, 76, 167, 1);
    }
  }
}
.my-border-container {
  width: 95%;
  height: 450px;
  border: 1px solid #004ca7;
  opacity: 0.8;
  border-radius: 5px;
}
</style>
<style scoped lang="less">
.assessment-edit-plan-container {
  .assessment-design {
    padding: 25px 38px !important;
  }

  .button-group {
    cursor: pointer;
    margin: 50px 0;
    text-align: center;

    > div {
      display: inline-block;
      font-size: 18px;
      padding: 6px 22px;
      border-radius: 4px;

      &:nth-child(1) {
        color: #f3b815;
        border: 1px solid #f3b815;
        background: #fff6ef;
        margin-right: 140px;
      }

      &:nth-child(2) {
        color: #02C86C;
        border: 1px solid #02C86C;
        background: #f1fff8;
        margin-right: 140px;
      }
      &:nth-child(3) {
        color: #ff3819;
        border: 1px solid #ff3819;
        background: #ffefef;
      }
    }
  }
}
@fontFamily:"Microsoft YaHei";
.xpaas-table-class {
  margin-top: 15px;
  border: 1px solid #004ca7;
  border-radius: 9px;
  > ::v-deep div.el-table__header-wrapper {
    > table.el-table__header {
      > thead {
        > tr.xpaas-header-row-class {
          padding: 0;
          // height: 76px;
          background-color: #edf2f9;
          font-size: 16px;
          font-family: Microsoft YaHei;
          font-weight: bold;
          line-height: 20px;
          color: #004ca7;
          > th.xpaas-header-cell-class {
            font-weight: bold;
            border-right: 1px solid #c7d7eb;
            border-left: 0;
            border-bottom: 1px solid #c7d7eb;
            background-color: #edf2f9;
            > div.cell {
              font-size: 16px;
              font-weight: bold;
              font-family: @fontFamily;
              color: #004ca7;
            }
          }
        }
      }
    }
  }
  > ::v-deep div.el-table__body-wrapper {
    > table.el-table__body {
      > tbody {
        > tr.xpaas-row-class {
          > td.xpaas-header-cell-class {
            border-right: 1px solid #c7d7eb;
            border-left: 0;
            border-bottom: 1px solid #c7d7eb;
            background-color: #edf2f9;
            > div.cell {
              font-size: 16px;
              font-weight: bold;
              font-family: @fontFamily;
              color: #004ca7;
            }
          }
          > td.xpaas-cell-class {
            // height: 76px;

            border-right: 1px solid #c7d7eb;
            border-left: 0;
            border-bottom: 1px solid #c7d7eb;
            > div.cell {
              font-weight: normal;
              font-family: @fontFamily;
              color: #004ca7;
            }
          }
        }
      }
    }
  }
}
</style>
